SELECT CASE TRUE
When the TRUE option is added to the SELECT CASE statement, CASE expressions match if they
are TRUE. The TRUE option can be used with any mix of numeric and string
cases. ALL can be combined with TRUE if desired.
SELECT CASE TRUE
SELECT CASE ALL TRUE
SELECT CASE FALSE
The FALSE option works like the TRUE option except the CASE expressions are tested for
FALSE instead of TRUE. SELECT CASE FALSE is similar to SELECT CASE 0, but it is
faster and can test any mix of numeric and string types.
SELECT CASE FALSE
SELECT CASE ALL FALSE
example 1
With the TRUE option, any combination of test conditions can be accommodated, as
demonstrated below:
SELECT CASE TRUE
CASE a
:
PRINT "Variable 'a' is TRUE"
CASE a*b+c*d : PRINT
"Expression 'a*b+c*d' is TRUE"
CASE (x < y), (y < z) : PRINT "(x < y) or (y < z) is
TRUE"
CASE p$, q$, r$, s$ : PRINT "At least 1 string has
contents"
CASE a[], b[], c[] : PRINT "At least 1 array has
contents"
CASE j, r$, p[a-b] : PRINT "At least 1 is TRUE"
CASE j, k, l : PRINT j,
k, l
CASE humidity > 100 : PRINT "The sky is falling."
CASE a$, b$+c$ : PRINT "a$ or
b$+c$ or both empty."
CASE !raining : PRINT
"You can go out now."
CASE ERROR(-1) : PRINT
"There's an ERROR."
CASE hope[] :
PRINT "There is hope[]."
CASE x$ < CHR$(x) : PRINT "x string < x
number."
CASE ELSE
: PRINT
"Nothing tested is true."
END SELECT
example 2
In the following example, ALL cases that are true will execute.
SELECT CASE ALL TRUE
CASE j, k, l : PRINT j,
k, l
CASE humidity > 100 : PRINT "The sky is falling."
CASE a$, b$+c$ : PRINT "a$ or
b$+c$ not empty."
CASE !raining : PRINT
"You can go out now."
CASE ERROR(-1) : PRINT "There's
an ERROR."
CASE hope[] :
PRINT "There is hope[]."
CASE x$ < CHR$(x) : PRINT "x string < x
number."
CASE ALL
: PRINT
"All printed are true."
END SELECT